<%--
    Document   : noticiaSearch
    Created on : 15/07/2013, 20:28:20
    Author     : Max
    Description:
        Esse documento JSP é utilizado para
--%>
<%@page import="Model.Noticia"%>
<%@page import="java.util.List"%>
<%
    List<Noticia> noticias = (List<Noticia>) request.getAttribute("noticias");
    if (noticias == null) {
        response.sendError(404);
    }
%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <%@include file="interfaceHead.jsp" %>
    </head>

    <body>
        <div class="nonFooter">
            <%--HEADER--%>
            <%@include file="interfaceHeader.jsp" %>

            <%--MAIN--%>
            <div id="main" class="container">
                <div class="row">
                    <nav class="span3">
                        <%@include file="interfaceNavigation.jsp" %>
                    </nav>
                    <div class="span9">
                        <h1>Pesquisar notícias</h1>
                        <form action="" method="get"
                              class="well">

                            <label for="keyword">Palavra chave</label>
                            <input type="text" name="keyword" value=""
                                   id="keyword" class="input-xxlarge"
                                   placeholder="Pesquise por uma palavra chave"/>

                            <div class="search-filter">

                                <label>Data de publicação</label>
                                <div class="controls controls-row">
                                    <input type="text" name="inicio" value=""
                                           id="inicio" class="dateITA span3"
                                           placeholder="Data de inicio">
                                    <input type="text" name="fim" value=""
                                           id="fim" class="dateITA span3"
                                           placeholder="Data de fim">
                                </div>

                            </div>

                            <div class="form-actions">
                                <button type="submit" name="action" value="search"
                                        class="btn btn-large btn-primary">
                                    Pesquisar
                                </button>
                                <button type="reset"
                                        class="btn btn-large"
                                        data-search-filter="button">
                                    Filtros
                                </button>
                            </div>
                        </form>

                        <%@include file="interfaceMessages.jsp" %>

                        <table class="table table-striped"
                               data-provides="rowlink">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>Data</th>
                                    <th>Título</th>
                                </tr>
                            </thead>
                            <tbody>
                                <%
                                    for (Noticia noticia : noticias) {
                                %>
                                <tr>
                                    <td><a href="noticia?action=view&id=<%= noticia.getId()%>"><%= noticia.getId()%></a></td>
                                    <td><%= noticia.printDataHora()%></td>
                                    <td><%= noticia.printTitulo()%></td>
                                </tr>
                                <%                                    }
                                %>
                            </tbody>
                            <tfoot>
                                <tr>
                                    <th>Resultados:</th>
                                    <th colspan="2"><%= noticias.size()%></th>
                                </tr>
                            </tfoot>
                        </table>

                    </div>

                </div>
            </div>

            <%--StickyFooter--%>
            <div id="push"></div>
        </div>
        <%@include file="interfaceFooter.jsp" %>
    </body>
</html>

